using System;
using System.Collections;
using System.Threading;
using System.Web;
using Sedna.Core.Controller;
using Sedna.Core.Controller.Common;
using Sedna.Core.Security;

namespace Sedna.UI.Access.Actions
{
	/// <summary>
	/// logs out a currently logged in user from both HttpSession, including cookie and from the underlying 
	/// authentication mechanism (by calling the corresponding SingOut() method).
	/// After logging out - redirects to the Sedna default page (which is set up via collaborator).
	/// </summary>
	public class LogoutAction : AbstractAction
	{

		IAuthenticator authenticator;
		string defaultPage;

		public IAuthenticator Authenticator
		{
			set { authenticator = value; }
		}

		public string DefaultPage
		{
			set { defaultPage = value; }
		}

		public override IActionResult Execute(IExecutionContext executionContext)
		{
			//authenticator.SignOut(Thread.CurrentPrincipal);

			//PrincipalCookieUtil.SignOut(HttpContext.Current);
            UserMapper.RemoveUser();

			HttpContext.Current.Response.Redirect(defaultPage, true);

			return CreateResult(successStatus);
		}
	}
}
